/*
 * @Author: liuxinyea
 * @Date: 2024-08-11 23:00:44
 * @LastEditors: liuxinyea
 * @LastEditTime: 2024-08-11 23:11:46
 * @Description: 描述
 */
import { _decorator, Component, EventMouse, Input, Node, tween, Vec3 } from 'cc';
import { SunManager } from './manager/SunManager';
const { ccclass, property } = _decorator;

@ccclass('Sun')
export class Sun extends Component {
    protected onLoad(): void {
        this.node.on(Input.EventType.MOUSE_DOWN,this.onMouseDown,this)
    }
    onMouseDown(event:EventMouse) {
        this.collectSun()
    }
    // 点击收集阳光的方法，更新位置，添加分数，然后消失
    public collectSun() {
        tween(this.node).to(0.5,{position:new Vec3(-325,330,0)},{
            onComplete:()=>{
                this.node.destroy();
                SunManager.instance.addPoint(50);
            }
        }).start();
       
    }

}

